package org.hengguan.api.contest.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@MapperScan({ "org.hengguan.base.contest.mapper", "org.hengguan.api.contest.module.*.mapper" })
@Configuration
public class MybatisPlusConfig {

//	@Bean
//	public MybatisPlusInterceptor mybatisPlusInterceptor() {
//		MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
//		DynamicTableNameInnerInterceptor dynamicTableNameInnerInterceptor = new DynamicTableNameInnerInterceptor();
//		TableNameHandler tableNameHandler = new TableNameHandler() {
//			@Override
//			public String dynamicTableName(String sql, String tableName) {
//				log.info(sql);
//				log.info(sql);
//				
////				role_name='min13'
//				return tableName;
//			}
//		};
//		Map<String, TableNameHandler> tableNameHandlerMap = new HashMap<>();
//		tableNameHandlerMap.put("tb_sys_role_info_web", tableNameHandler);
//		dynamicTableNameInnerInterceptor.setTableNameHandlerMap(tableNameHandlerMap);
//		DynamicTableNameParser dynamicTableNameParser = new DynamicTableNameParser();
//		mybatisPlusInterceptor.addInnerInterceptor(dynamicTableNameInnerInterceptor);
//		return mybatisPlusInterceptor;
//	}
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return mybatisPlusInterceptor;
    }
	
//	@Bean
//	public IdentifierGenerator identifierGenerator() {
//	    return new IdentifierGenerator() {
//			@Override
//			public Number nextId(Object entity) {
//				return TianyiIdUtil.nextId();
//			}
//		};
//	}


}
